using System;
using System.Collections.Generic;
using System.Text;
using System.Data;

namespace DTO
{
	/// <summary> 
	///Author: nnamthach@gmail.com 
	/// <summary>
    public class VENDORInfo
    {
		#region Local Variable
        public enum Field{
			VendorCode,
			VendorName,
			Beneficiary,
			BankName,
			AccountNo1,
			AccountNo2,
			SwiftCode,
			VATCode,
			Address,
			Fax_Tel,
			Email,
			ContactPerson,
			Note1,
			Note2,
			PaymentTerm,
			BankAddress
        }
		private String _VendorCode;
		public String VendorCode
		{
			get { return _VendorCode; }
			set { _VendorCode = value; }
		}
		private String _VendorName;
		public String VendorName
		{
			get { return _VendorName; }
			set { _VendorName = value; }
		}
		private String _Beneficiary;
		public String Beneficiary
		{
			get { return _Beneficiary; }
			set { _Beneficiary = value; }
		}
		private String _BankName;
		public String BankName
		{
			get { return _BankName; }
			set { _BankName = value; }
		}
		private String _AccountNo1;
		public String AccountNo1
		{
			get { return _AccountNo1; }
			set { _AccountNo1 = value; }
		}
		private String _AccountNo2;
		public String AccountNo2
		{
			get { return _AccountNo2; }
			set { _AccountNo2 = value; }
		}
		private String _SwiftCode;
		public String SwiftCode
		{
			get { return _SwiftCode; }
			set { _SwiftCode = value; }
		}
		private String _VATCode;
		public String VATCode
		{
			get { return _VATCode; }
			set { _VATCode = value; }
		}
		private String _Address;
		public String Address
		{
			get { return _Address; }
			set { _Address = value; }
		}
		private String _Fax_Tel;
		public String Fax_Tel
		{
			get { return _Fax_Tel; }
			set { _Fax_Tel = value; }
		}
		private String _Email;
		public String Email
		{
			get { return _Email; }
			set { _Email = value; }
		}
		private String _ContactPerson;
		public String ContactPerson
		{
			get { return _ContactPerson; }
			set { _ContactPerson = value; }
		}
		private String _Note1;
		public String Note1
		{
			get { return _Note1; }
			set { _Note1 = value; }
		}
		private String _Note2;
		public String Note2
		{
			get { return _Note2; }
			set { _Note2 = value; }
		}
		private Int32 _PaymentTerm;
		public Int32 PaymentTerm
		{
			get { return _PaymentTerm; }
			set { _PaymentTerm = value; }
		}
		private String _BankAddress;
		public String BankAddress
		{
			get { return _BankAddress; }
			set { _BankAddress = value; }
		}
        #endregion LocalVariable
        
        #region Constructor
		public VENDORInfo()
		{
			_VendorCode = "";
			_VendorName = "";
			_Beneficiary = "";
			_BankName = "";
			_AccountNo1 = "";
			_AccountNo2 = "";
			_SwiftCode = "";
			_VATCode = "";
			_Address = "";
			_Fax_Tel = "";
			_Email = "";
			_ContactPerson = "";
			_Note1 = "";
			_Note2 = "";
			_PaymentTerm = -1;
			_BankAddress = "";
		}
		public VENDORInfo(
			String VendorCode,
			String VendorName,
			String Beneficiary,
			String BankName,
			String AccountNo1,
			String AccountNo2,
			String SwiftCode,
			String VATCode,
			String Address,
			String Fax_Tel,
			String Email,
			String ContactPerson,
			String Note1,
			String Note2,
			Int32 PaymentTerm,
			String BankAddress
			)
		{
			_VendorCode = VendorCode;
			_VendorName = VendorName;
			_Beneficiary = Beneficiary;
			_BankName = BankName;
			_AccountNo1 = AccountNo1;
			_AccountNo2 = AccountNo2;
			_SwiftCode = SwiftCode;
			_VATCode = VATCode;
			_Address = Address;
			_Fax_Tel = Fax_Tel;
			_Email = Email;
			_ContactPerson = ContactPerson;
			_Note1 = Note1;
			_Note2 = Note2;
			_PaymentTerm = PaymentTerm;
			_BankAddress = BankAddress;
		}
		public VENDORInfo(DataRow dr)
		{
			if (dr != null)
			{
				_VendorCode = dr["VendorCode"] == DBNull.Value ? "" : (String)dr["VendorCode"];
				_VendorName = dr["VendorName"] == DBNull.Value ? "" : (String)dr["VendorName"];
				_Beneficiary = dr["Beneficiary"] == DBNull.Value ? "" : (String)dr["Beneficiary"];
				_BankName = dr["BankName"] == DBNull.Value ? "" : (String)dr["BankName"];
				_AccountNo1 = dr["AccountNo1"] == DBNull.Value ? "" : (String)dr["AccountNo1"];
				_AccountNo2 = dr["AccountNo2"] == DBNull.Value ? "" : (String)dr["AccountNo2"];
				_SwiftCode = dr["SwiftCode"] == DBNull.Value ? "" : (String)dr["SwiftCode"];
				_VATCode = dr["VATCode"] == DBNull.Value ? "" : (String)dr["VATCode"];
				_Address = dr["Address"] == DBNull.Value ? "" : (String)dr["Address"];
				_Fax_Tel = dr["Fax_Tel"] == DBNull.Value ? "" : (String)dr["Fax_Tel"];
				_Email = dr["Email"] == DBNull.Value ? "" : (String)dr["Email"];
				_ContactPerson = dr["ContactPerson"] == DBNull.Value ? "" : (String)dr["ContactPerson"];
				_Note1 = dr["Note1"] == DBNull.Value ? "" : (String)dr["Note1"];
				_Note2 = dr["Note2"] == DBNull.Value ? "" : (String)dr["Note2"];
				_PaymentTerm = dr["PaymentTerm"] == DBNull.Value ? -1 : (Int32)dr["PaymentTerm"];
				_BankAddress = dr["BankAddress"] == DBNull.Value ? "" : (String)dr["BankAddress"];
			}
		}

        public VENDORInfo(DataRowView dr)
        {
            if (dr != null)
            {
                _VendorCode = dr["VendorCode"] == DBNull.Value ? "" : (String)dr["VendorCode"];
                _VendorName = dr["VendorName"] == DBNull.Value ? "" : (String)dr["VendorName"];
                _Beneficiary = dr["Beneficiary"] == DBNull.Value ? "" : (String)dr["Beneficiary"];
                _BankName = dr["BankName"] == DBNull.Value ? "" : (String)dr["BankName"];
                _AccountNo1 = dr["AccountNo1"] == DBNull.Value ? "" : (String)dr["AccountNo1"];
                _AccountNo2 = dr["AccountNo2"] == DBNull.Value ? "" : (String)dr["AccountNo2"];
                _SwiftCode = dr["SwiftCode"] == DBNull.Value ? "" : (String)dr["SwiftCode"];
                _VATCode = dr["VATCode"] == DBNull.Value ? "" : (String)dr["VATCode"];
                _Address = dr["Address"] == DBNull.Value ? "" : (String)dr["Address"];
                _Fax_Tel = dr["Fax_Tel"] == DBNull.Value ? "" : (String)dr["Fax_Tel"];
                _Email = dr["Email"] == DBNull.Value ? "" : (String)dr["Email"];
                _ContactPerson = dr["ContactPerson"] == DBNull.Value ? "" : (String)dr["ContactPerson"];
                _Note1 = dr["Note1"] == DBNull.Value ? "" : (String)dr["Note1"];
                _Note2 = dr["Note2"] == DBNull.Value ? "" : (String)dr["Note2"];
                _PaymentTerm = dr["PaymentTerm"] == DBNull.Value ? -1 : (Int32)dr["PaymentTerm"];
                _BankAddress = dr["BankAddress"] == DBNull.Value ? "" : (String)dr["BankAddress"];
            }
        }
        #endregion Constructor
        
        #region InitTable
		public static DataTable ToDataTable()
		{
			DataTable dt = new DataTable("TblVENDOR");
			dt.Columns.AddRange(new DataColumn[] { 
				new DataColumn("VendorCode", typeof(String)),
				new DataColumn("VendorName", typeof(String)),
				new DataColumn("Beneficiary", typeof(String)),
				new DataColumn("BankName", typeof(String)),
				new DataColumn("AccountNo1", typeof(String)),
				new DataColumn("AccountNo2", typeof(String)),
				new DataColumn("SwiftCode", typeof(String)),
				new DataColumn("VATCode", typeof(String)),
				new DataColumn("Address", typeof(String)),
				new DataColumn("Fax_Tel", typeof(String)),
				new DataColumn("Email", typeof(String)),
				new DataColumn("ContactPerson", typeof(String)),
				new DataColumn("Note1", typeof(String)),
				new DataColumn("Note2", typeof(String)),
				new DataColumn("PaymentTerm", typeof(Int32)),
				new DataColumn("BankAddress", typeof(String))
				});
			return dt;
		}
		public DataRow ToDataRow(DataTable dt)
		{
			DataRow row = dt.NewRow();
			row["VendorCode"] = _VendorCode;
			row["VendorName"] = _VendorName;
			row["Beneficiary"] = _Beneficiary;
			row["BankName"] = _BankName;
			row["AccountNo1"] = _AccountNo1;
			row["AccountNo2"] = _AccountNo2;
			row["SwiftCode"] = _SwiftCode;
			row["VATCode"] = _VATCode;
			row["Address"] = _Address;
			row["Fax_Tel"] = _Fax_Tel;
			row["Email"] = _Email;
			row["ContactPerson"] = _ContactPerson;
			row["Note1"] = _Note1;
			row["Note2"] = _Note2;
			row["PaymentTerm"] = _PaymentTerm;
			row["BankAddress"] = _BankAddress;
			return row;
		}
        #endregion InitTable
    }
}
